Skip to content

Add Vitest config and tests for pictures API and ModalPic#10

Merged
Jophkins merged 2 commits intomainfrom
codex/add-unit-tests
Jan 31, 2026
Merged

Add Vitest config and tests for pictures API and ModalPic#10
Jophkins merged 2 commits intomainfrom
codex/add-unit-tests

Conversation

@Jophkins
Copy link
Owner

Motivation

  • Add automated tests to validate the pictures API pagination behavior including the default when cursor is omitted.
  • Provide a local Vitest configuration and test setup to run component and node-style API tests in a jsdom environment.
  • Make component rendering deterministic in tests by mocking Next.js Image so UI tests can assert markup and interactions.

Description

  • Added tests/api/pictures-route.test.ts which covers the /api/pictures route including the omitted cursor default, initial page, and final page cases.
  • Added tests/components/shared/modal-pic.test.tsx which asserts ModalPic renders content and calls onClose on Escape and overlay click.
  • Added tests/setup.tsx to mock next/image for the test environment and imported @testing-library/jest-dom/vitest for assertions.
  • Added vitest.config.ts and updated package.json to include vitest/testing scripts and related devDependencies and scripts.

Testing

  • Ran the repository linter via pnpm lint, which completed successfully as part of the pre-commit tasks.
  • Could not run pnpm test/vitest in this environment because the test dependencies were not installed, so the new tests were not executed here.

Codex Task

@Jophkins Jophkins merged commit edf5ec0 into main Jan 31, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant